package com.example.test.file;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import java.io.File;

@Slf4j
public class FileListener extends FileAlterationListenerAdaptor {
    @Override
    public void onStart(FileAlterationObserver observer) {
        super.onStart(observer);
    }

    @Override
    public void onStop(FileAlterationObserver observer) {
        super.onStop(observer);
    }

    @Override
    public void onFileCreate(File file) {
        super.onFileCreate(file);
        log.info("[新建]:" + file.getAbsolutePath());
    }

    @Override
    public void onFileChange(File file) {
        super.onFileChange(file);
        log.info("[修改]:" + file.getAbsolutePath());
    }

    @Override
    public void onFileDelete(File file) {
        super.onFileDelete(file);
        log.info("[删除]:" + file.getAbsolutePath());
    }

    @Override
    public void onDirectoryCreate(File directory) {
        log.info("[新建]:" + directory.getAbsolutePath());
        super.onDirectoryCreate(directory);
    }

    @Override
    public void onDirectoryChange(File directory) {
        super.onDirectoryChange(directory);
    }

    @Override
    public void onDirectoryDelete(File directory) {
        super.onDirectoryDelete(directory);
    }
}
